<%@ page language="java" contentType="text/html; charset=utf-8"
     pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>login</title>
        
        <script src="../assets/jquery/jquery-1.9.1.min.js"></script>
        
        <style type="text/css">
        	td{text-align:center;width:80px;}
        </style>
        
    </head>
    <body>
    	<h1>这是登录页面</h1>
    	
    	账户：<input type="text" id="username" /> <br />
    	密码：<input type="password" id="password" /><br />
        
        <button onclick="sub()">提交</button>
        <button onclick="reset()">重置</button><br />
        
        <span>测试nginx+redis实现session一致性</span>
        
        <script type="text/javascript">
        	
        	var basePath = "http://192.168.119.130/firweb";
        	
        	function sub(){
        		var username = $("#username").val();
        		var password = $("#password").val();
        		$.ajax({
        			url:basePath+"/session/login",
        			data:{"username":username,"password":password},
        			type:"post",
        			dataType:"text",
        			success:function(data){
        				console.log(data);
        				if(data == "success"){
	        				window.location.href = basePath+"/session/userCenter";
        				}else{
        					alert("输入内容不能为空");
        				}
        			},
        			error:function(data){
        				console.log(data);
        			}
        			
        		});
        	}
        
        	function reset(){
        		$("#username").val("");
        		$("#password").val("");
        		
        	}
        	
        </script>
        
    </body>
</html>